package Qm;

import java.util.ArrayList;

public class ArrayLIst {
    public static void main(String[] args) {


            ArrayList<Student2> list=new ArrayList<>();

            list.add(new Student2(1,"张三"));
            list.add(new Student2(2,"李四"));
            list.add(new Student2(3,"王五"));

            System.out.println(list);

            for (int i=0; i<list.size();i++){
                Student2 student=list.get(i);

                if (student.getName().equals("张三")){
                    student.setName("张三丰");

                }
                if (student.getName().equals("王五")){
                    list.remove(student);
                }
            }
            System.out.println(list);

        }
}